#include <map>
#include <string>
#include <vector>
#include <functional>
#include <iostream>

class EventManager {
    std::map<std::string, std::vector<std::function<void()>>> listeners;

public:
    void subscribe(const std::string& event, std::function<void()> callback) {
        listeners[event].push_back(callback);
    }

    void emit(const std::string& event) {
        for (auto& listener : listeners[event]) {
            listener(); 					//通知所有监听者
        }
    }
};

void onKeyPressed() {
    std::cout << "Key Pressed Event Triggered!" << std::endl;
}

int main() {
    EventManager manager;
    manager.subscribe("keyPressed", onKeyPressed);

    manager.emit("keyPressed");
    return 0;
}